package wb.is.besti.edu.cd.javalibgame;

import android.animation.Animator;
import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.View;
import android.widget.Button;

import com.airbnb.lottie.LottieAnimationView;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * Created by asus on 2017/12/11.
 */

public class First_page extends Activity {
    @Bind(R.id.view1)
    LottieAnimationView view1;
    @Bind(R.id.view2)
    LottieAnimationView view2;
    @Bind(R.id.view3)
    LottieAnimationView view3;
    @Bind(R.id.view4)
    LottieAnimationView view4;
    @Bind(R.id.view5)
    LottieAnimationView view5;
    @Bind(R.id.view6)
    LottieAnimationView view6;
    @Bind(R.id.view7)
    LottieAnimationView view7;

    @Bind(R.id.btn_enter)
    Button start;
    @Bind(R.id.btn_madou)
    Button moudle;
    @Bind(R.id.bte_dev)
    Button devo;


    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.first_menu);
        ButterKnife.bind(this);
        init();
        start.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(First_page.this,MainActivity.class);
                startActivity(intent);
                finish();
            }
        });

        moudle.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(First_page.this,moshijieshao.class);
                startActivity(intent);
            }
        });
        devo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent(First_page.this,developer.class);
                startActivity(intent);
            }
        });

    }
    private void init(){
        view1.removeAnimatorListener(myAnimatorListener1);
        view2.removeAnimatorListener(myAnimatorListener2);
        view3.removeAnimatorListener(myAnimatorListener3);
        view4.removeAnimatorListener(myAnimatorListener4);
        view5.removeAnimatorListener(myAnimatorListener5);
        view6.removeAnimatorListener(myAnimatorListener6);
        view7.removeAnimatorListener(myAnimatorListener7);
        startAnimation();

    }
    private void startAnimation(){
        view1.setProgress(0f);
        view1.setAnimation("Mobilo/J.json");
        view1.loop(true);
        view1.playAnimation();
        view1.addAnimatorListener(myAnimatorListener1);
        view2.setProgress(0f);
        view2.setAnimation("Mobilo/A.json");
        view2.loop(true);
        view2.playAnimation();
        view2.addAnimatorListener(myAnimatorListener2);
        view3.setProgress(0f);
        view3.setAnimation("Mobilo/V.json");
        view3.loop(true);
        view3.playAnimation();
        view3.addAnimatorListener(myAnimatorListener3);

        view4.setProgress(0f);
        view4.setAnimation("Mobilo/A.json");
        view4.loop(true);
        view4.playAnimation();
        view4.addAnimatorListener(myAnimatorListener4);

        view5.setProgress(0f);
        view5.setAnimation("Mobilo/L.json");
        view5.loop(true);
        view5.playAnimation();
        view5.addAnimatorListener(myAnimatorListener5);

        view6.setProgress(0f);
        view6.setAnimation("Mobilo/A.json");
        view6.loop(true);
        view6.playAnimation();
        view6.addAnimatorListener(myAnimatorListener6);

        view7.setProgress(0f);
        view7.setAnimation("Mobilo/B.json");
        view7.loop(true);
        view7.playAnimation();
        view7.addAnimatorListener(myAnimatorListener7);
    }
    private Animator.AnimatorListener myAnimatorListener1 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
                view1.setAnimation("Mobilo/J.json");
                view1.loop(true);
                view1.playAnimation();

        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener2 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
                    view2.setAnimation("Mobilo/A.json");
                    view2.loop(true);
                    view2.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener3 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view3.setAnimation("Mobilo/V.json");
            view3.loop(true);
            view3.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener4 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
                    view4.setAnimation("Mobilo/A.json");
                    view4.loop(true);
                    view4.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener5 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view5.setAnimation("Mobilo/L.json");
            view5.loop(true);
            view5.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener6 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view6.setAnimation("Mobilo/A.json");
            view6.loop(true);
            view6.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
    private Animator.AnimatorListener myAnimatorListener7 = new Animator.AnimatorListener() {
        @Override
        public void onAnimationStart(Animator animation) {

        }

        @Override
        public void onAnimationEnd(Animator animation) {
            view7.setAnimation("Mobilo/B.json");
            view7.loop(true);
            view7.playAnimation();
        }

        @Override
        public void onAnimationCancel(Animator animation) {

        }

        @Override
        public void onAnimationRepeat(Animator animation) {

        }
    };
}
